package com.bjsxt.service.impl;

import com.bjsxt.mapper.CompanyMapper;
import com.bjsxt.pojo.Company;
import com.bjsxt.pojo.PageA;
import com.bjsxt.service.CompanyService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CompanyServiceImpl implements CompanyService {
    @Autowired
    private CompanyMapper companyMapper;
    @Override
    public PageA<Company> findCompany(Integer start, Integer rows,Company company) {
        Page pg = PageHelper.startPage(start, rows);
        List<Company> companies = companyMapper.selectCompanys(company);

        PageA<Company> pga = new PageA<>(companies,pg.getTotal());
        return pga;
    }

    @Override
    public Integer addCompany(Company company) {
        return companyMapper.insertCompany(company);
    }

    @Override
    public Integer changeCompany(Company company) {
        return companyMapper.updateCompany(company);
    }
}
